package com.bookmarket.service.impl;

import com.bookmarket.dao.LJOrderListMapper;
import com.bookmarket.entity.*;
import com.bookmarket.service.LJOrderListService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;


@Service("/lJOrderListService")
public class LJOrderListServiceImpl implements LJOrderListService{

    @Resource
    private LJOrderListMapper ljOrderListMapper;


    //根据前台传过来的name查询对应用户所有的信息
    public Custom selectBy(String name){
        return ljOrderListMapper.selectBy(name);
    }
    //查询地址
    public List<Address> selectByCustom(Custom custom){
        return ljOrderListMapper.selectByCustom(custom);
    }
    //添加地址
    public boolean insertAddress(Address address){
        return ljOrderListMapper.insertAddress(address);
    }
    //删除地址
    public boolean delAddress(int id){
        return ljOrderListMapper.delAddress(id);
    }
    //修改地址
    public boolean updateAddress(Address address){
        return ljOrderListMapper.updateAddress(address);
    }

    @Override
    public boolean insertByOrder2(Map map) {
        return ljOrderListMapper.insertByOrder2(map);
    }

    @Override
    public boolean deleteBookById(int id){
        return ljOrderListMapper.deleteBookById(id);
    }

    /*****************************************************************************************/
    //根据地址id查询对应的地址
    public Address selectById(int id){
        return ljOrderListMapper.selectById(id);
    }
    //向订单表插入地址表相关信息
    public boolean insertByOrder(Order order){
        return ljOrderListMapper.insertByOrder(order);
    }
    //根据商品id查询对应的商品信息
    public Shop selectByShopId(int id){
        return ljOrderListMapper.selectByShopId(id);
    }
    //查看刚刚插入订单的主键id
    public Order selectByOrder(Order order){
        return ljOrderListMapper.selectByOrder(order);
    }
    //向关系表tb_order_book存数据
    public  boolean insertOrderBook(Order_Book order_book){
        return ljOrderListMapper.insertOrderBook(order_book);
    }

    @Override
    public boolean delOrderByOrderList(int id) {
        return ljOrderListMapper.delOrderByOrderList(id);
    }

    /*******************************************************************************************/
    @Override
    public List<Map> queryDiscount(int customId) {
        return ljOrderListMapper.queryDiscount(customId);
    }

    @Override
    public boolean deleteDiscount(int id){
        return ljOrderListMapper.deleteDiscount(id);
    }

    @Override
    public boolean modOrderState(int id){
        return ljOrderListMapper.modOrderState(id);
    }

    //根据商品id查看商品表中book_id(外键值)
    public int chaId(int id){
        return ljOrderListMapper.chaId(id);
    }
    //根据地址id查看地址表中custom_id(外键值)
    public int chaAddressId(int id){
        return ljOrderListMapper.chaAddressId(id);
    }



    /*****************************************************************************************/
    public LJOrderListMapper getLjOrderListMapper() {
        return ljOrderListMapper;
    }

    public void setLjOrderListMapper(LJOrderListMapper ljOrderListMapper) {
        this.ljOrderListMapper = ljOrderListMapper;
    }


}
